package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported
/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class DVDCtr
{
    //declare instance variables to reference containers
    //passed as arguments from the main class
    
    private DVDContainer dvdCon;

    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()
    {
        //set up references to containers
        dvdCon = new DVDContainer();
    }
    
    //Dummy implementation: after implementing the model layer 
    //objects of class DVD are to be returned, not String
    public DVD findDVD(String title)
    {
        DVD d = dvdCon.readDVD(title);
        return d;
    }
    
    public void createDVD(String title, String publisher, String releaseYear)
    {
        //creates a DVD object and stores it in the container
        DVD d = new DVD(title, publisher, releaseYear);
        dvdCon.addDVD(d);
    }
    
    public void deleteDVD(String title)
    {
        //search for the dvd and delete the object from the container
        DVD d = dvdCon.readDVD(title);
        dvdCon.removeDVD(d);
       
    }
    
    public ArrayList<DVD> listAllDvds()
    {
          //returns a list of all dvds and their associated copies
          ArrayList<DVD> d = dvdCon.listAllDVDs();
          return d;
    }
}
